#include"student.h"

int Student::count = 0;

Student::Student()
{
    name = "NULL";
    ID = "NULL";
    GPA = -1;
}

Student::Student(string na, string id)
{
    name = na;
    ID = id;
    GPA = 0;
    count++;
}

string Student::GetName()const
{
    return name;
}

double Student::GetGPA()const
{
    return GPA;
}

void Student::ReckonGPA(const Subject& sub)
{
    GPA =  (    (sub.score[0]-60)/40.0 * sub.SMath * sub.SMath
            +   (sub.score[0]-60)/40.0 * sub.SEng * sub.SEng
            +   (sub.score[0]-60)/40.0 * sub.SCpp * sub.SCpp    )
            /   (sub.SMath + sub.SEng + sub.SCpp);
}

void Student::Display(const Subject& sub)const
{
    cout << "姓 名：" << name << endl;
    cout << "学 号：" << ID << endl;
    cout << " Math " << " SEng " << " SCpp " << endl;
    for (int i = 0; i < 3; i++)
    {
        cout << sub.score[i] << " ";
    }
    cout << endl;
    cout << " GPA : " << GPA << endl << endl;
}

void Student::Display()const
{
    cout << "姓 名：" << name << endl;
    cout << "学 号：" << ID << endl;
}

void Student::Input()
{
    cout << "输入姓 名：" ;
    cin >> name;
    cout << "输入学 号：";
    cin >> ID;
    count++;
}

void Student::Insert()
{
    if (GPA < 0)
        Input();
}

void Student::Delete()
{
    GPA = -1;
    count--;
}

int Student::GetCount()
{
    return count;
}






